
var timeid;
var im = {
	account:'',
	password:'',
	token:'',
	uid:'',
	onlines:[],
	server_url:'',
	im_server_url:'ws://115.28.167.223:9999',
	ws:'',


	init:function (){
		this.ws = new WebSocket('ws://115.28.167.223:9999');
		this.ws.onopen = function() {
			timeid && window.clearInterval(timeid);
			im.ws.send(JSON.stringify({"type":"login","token":""}));
		};
		// 当有消息时根据消息类型显示不同信息
		this.ws.onmessage = function(e) {
			console.log(e.data);
		};
		this.ws.onclose = function() {
			console.log("连接关闭，定时重连");
			// 定时重连
			window.clearInterval(timeid);
			timeid = window.setInterval(im.init, 3000);
		};
		this.ws.onerror = function() {

		};
	},
	getToken:function(){

	},
	login:function(){

	},

}

im.init();






